#include <QApplication>
#include <QQmlApplicationEngine>

#include <QtQml>
#include <QFileSystemModel>
class FilesModel : public QFileSystemModel
{
public:
    FilesModel(QObject *parent = 0L) : QFileSystemModel(parent)
    {
       setRootPath("c:/Windows");
    }

    virtual ~FilesModel() { }


    //Q_INVOKABLE
    QHash<int, QByteArray> roleNames() const {
        QHash<int, QByteArray> roles;
        roles[FileIconRole] = "icon";
        roles[FilePathRole] = "filePath";
        roles[FileNameRole] = "fileName";
        roles[FilePermissions] = "filePermsson";
        return roles;
    }

};


int main(int argc, char *argv[])
{
    QApplication app(argc, argv);

    qmlRegisterType<FilesModel>("com.filemanager", 1, 0, "FilesModel");

    QQmlApplicationEngine engine;
    //engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
    engine.load(QUrl(QStringLiteral("../pqfm/qml/main.qml")));

/*    QApplication app(argc, argv);
    QFileSystemModel *model = new QFileSystemModel();
    model->setRootPath("/home/user/");
    QDeclarativeView view;
    QDeclarativeEngine *engine = view.engine();
    QDeclarativeContext *context = view.rootContext();
    context->setContextProperty("qml_model",model);
    view.setSource(QUrl::fromLocalFile("example.qml"));
    QObject *rootObject = dynamic_cast<QObject*>(view.rootObject());
    view.setGeometry(QRect(0,0,840,480));
    view.showFullScreen();
    return app.exec();
*/
    return app.exec();
}
